package com.study.designpatterns.singleton;

/**
 * @author: jzhou
 * @date: 2025/6/15-12:15
 * @version: 1.0
 * @description: juc-study
 */
public class SingletonDCL {
    /**
     * 私有实例，volatile修饰的变量是具有可见性的（即被一个线程修改后，其他线程立即可见）
     */
    private static volatile SingletonDCL instance;
    private SingletonDCL(){}

    public static SingletonDCL getInstance(){
        if(instance == null){
            synchronized (SingletonDCL.class){
                if(instance == null){
                    instance = new SingletonDCL();
                }
            }
        }
        return instance;
    }
}
